package java6699.lesson08;

import java.util.Objects;

/**
 * @program: java_zzx
 * @description:
 * @author: zzx
 * @create: 2022-10-26 22:06
 **/
public class Course6699 implements Comparable<Course6699> {
    private String no;//课程编号
    private String name;//课程名称
    private String term;//开课学期
    private int credit;//学分
    private int score;//成绩

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Course6699 that = (Course6699) o;
        return Objects.equals(no, that.no) && Objects.equals(name, that.name) && Objects.equals(term, that.term) && Objects.equals(credit, that.credit) && Objects.equals(score, that.score);
    }

    @Override
    public int hashCode() {
        return Objects.hash(no, name, term, credit, score);
    }
    @Override
    public String toString() {
        return String.format("成绩：%d,%s,%d学分【%s %s】", score, term, credit, no, name);
    }


    public Course6699() {
    }

    public Course6699(String no, String name, String term, int credit, int score) {
        this.no = no;
        this.name = name;
        this.term = term;
        this.credit = credit;
        this.score = score;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTerm() {
        return term;
    }

    public void setTerm(String term) {
        this.term = term;
    }

    public int getCredit() {
        return credit;
    }

    public void setCredit(int credit) {
        this.credit = credit;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    @Override
    public int compareTo(Course6699 o) {
        return this.term.compareTo(o.term) == 0 ? this.credit - o.credit : this.term.compareTo(o.term);
    }
}
